package top.dancun.easbaseinfo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import top.dancun.common.utils.PageUtils;
import top.dancun.common.utils.Query;
import top.dancun.easbaseinfo.dao.TeacherDao;
import top.dancun.easbaseinfo.entity.TeacherEntity;
import top.dancun.easbaseinfo.service.TeacherService;

import java.util.Map;
import java.util.Objects;


@Service("teacherService")
public class TeacherServiceImpl extends ServiceImpl<TeacherDao, TeacherEntity> implements TeacherService {

    @Override
    public PageUtils queryPage(Map<String, Object> params,Map<String, String> dataParams) {
        IPage<TeacherEntity> page = new Query<TeacherEntity>().getPage(params);
        LambdaQueryWrapper<TeacherEntity> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(Objects.nonNull(dataParams.get("name")),TeacherEntity::getName,dataParams.get("name"))
                .eq(Objects.nonNull(dataParams.get("tId")),TeacherEntity::getTid,dataParams.get("tId"));
        this.baseMapper.querylist(page,wrapper,dataParams);

        return new PageUtils(page);
    }

}